package com.example.mysqlmycat.controller;

import com.example.mysqlmycat.mode.User;
import com.example.mysqlmycat.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("user")
public class UserController {

    /**
     * 控制层调用业务层
     */
    @Autowired
    private UserService userService;

    @GetMapping("save")
    public String saveUser(String username, String password) {
        User user = userService.saveUser(new User(username, password));
        if (user == null){
            return "保存失败";
        }else {
            return "保存成功";
        }
    }
}








